﻿@{
    ViewBag.Title = "微信用户管理";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script>
    $(function () {
        gridList();
    })

    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/WXStyle/GetGridJson",
            height: $(window).height() - 128,
            colModel: [
                { label: '主键', name: 'ID', hidden: true },
                { label: '微信ID', name: 'Openid', width: 220, align: 'left' },
                { label: '微信名', name: 'Nickname', width: 100, align: 'left' },
                {
                    label: '性别', name: 'Sex', width: 60, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return '女';
                        } else if (cellvalue == 0) {
                            return '男';
                        }
                    }
                },
                { label: '国家', name: 'Country', width: 80, align: 'left' },
                { label: '省份', name: 'Province', width: 80, align: 'left' },
                { label: '城市', name: 'Country', width: 80, align: 'left' },
                 { label: '添加时间', name: 'AddTime', width: 120, align: 'left' },
                 { label: '手机号', name: 'Tel', width: 110, align: 'left' },
                 { label: '最后登录时间', name: 'LastLoginTime', width: 120, align: 'left' },
                {
                    label: '状态', name: 'Status', width: 60, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return '正常';
                        } else if (cellvalue == 2) {
                            return '冻结';
                        }
                    }
                }
            ],
            pager: "#gridPager",
            sortname: 'ID asc,UpdateTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: {
                    UserName: $.trim($("#txt_UserName").val()),
                    UserTel: $.trim($("#txt_Tel").val()),
                    StartTime: $.trim($("#StartTime").val()),
                    EndTime: $.trim($("#EndTime").val())
                },
            }).trigger('reloadGrid');
        });
    }
    function btn_delete() {
        var keyValue = $("#gridList").jqGridRowValue().ID;
        $.deleteForm({
            url: "/WXStyle/DeleteForm",
            param: { keyValue: keyValue },
            prompt: "注：您确定要删除该用户吗？",
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_Agree() {
        var keyValue = $("#gridList").jqGridRowValue().ID;
        $.deleteForm({
            url: "/WXStyle/Agree",
            param: { keyValue: keyValue },
            prompt: "注：您确定要取消冻结该用户吗？",
            loading: "正在执行操作...",
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_Refuse() {
        var keyValue = $("#gridList").jqGridRowValue().ID;
        $.deleteForm({
            url: "/WXStyle/Refuse",
            param: { keyValue: keyValue },
            prompt: "注：您确定要冻结该用户吗？",
            loading: "正在执行操作...",
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_SetStyleToUser() {
        var keyValue = $("#gridList").jqGridRowValue().ID;
        $.deleteForm({
            url: "/WXStyle/SetStyleToUser",
            param: { keyValue: keyValue },
            prompt: "注：您确定要取消该用户的发型师身份吗？",
            loading: "正在执行操作...",
            success: function (data) {
                if (data.state == 1) {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
                else (data.state == 2)
                {
                    alert("请先删除系统中的发型师！");
                }
            }
        })
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增店面</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                @*<li class="first">已选中<span>1</span>项</li>*@
                @*<li><a id="NF-edit" authorize="yes" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改评论</a></li>
                <li><a id="NF-delete" authorize="yes" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除店面</a></li>*@
                <li><a id="NF-Details" authorize="yes" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看</a></li>
                <li class="split"></li>
                <li><a id="NF-disabled" authorize="yes" onclick="btn_Agree()"><i class="fa fa-stop-circle"></i>冻结用户</a></li>
                <li><a id="NF-disabled" authorize="yes" onclick="btn_Refuse()"><i class="fa fa-stop-circle"></i>取消冻结</a></li>
                <li><a id="NF-enabled" authorize="yes" onclick="btn_SetStyleToUser()"><i class="fa fa-play-circle"></i>取消发型师</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_UserName" type="text" class="form-control" placeholder="用户微信名" style="width: 120px;margin-left: 10px;" maxlength="25">
                        <input id="txt_Tel" type="text" class="form-control" placeholder="用户手机号" style="width: 120px;margin-left: 10px;" maxlength="25">
                        <input id="StartTime" name="SetUpTime" type="text" class="input-wdatepicker" style="width: 120px;margin-left: 10px;height:31px;"  onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" placeholder="开始时间">
                        <input id="EndTime" name="SetUpTime" type="text" class="input-wdatepicker" style="width: 120px;margin-left: 10px;height:31px;"  onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" placeholder="结束时间">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
